public class Problem {
        
    private Candidates candidates = new Candidates();
    private Solution solution = new Solution();
    
    /**
     * Solves the "Speelkaartenprobleem" by using a recursive backtracking
     * algorithm.
     */
    public void solve(){
        int index = 0;
        
        while(index < candidates.size()){
            if(solution.fits(candidates.get(index))){
            	solution.record(candidates.remove(index));
            	
            	if(solution.possible()){
            		if (solution.complete())
	                {
	                    solution.show();
	                }
	                else
	                {
	                    solve();
	                }
            	}
            	candidates.add(index, solution.eraseRecording());
            }
	        index++;
        }
    }
}